package com.maxwell.impl;

import com.maxwell.entity.Order;
import com.maxwell.inter.OrderManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Component;

/**
 * User:Maxwell
 * Date:2015/2/16
 * Time:11:42
 */
@Component
public class SimpleOrderManager implements OrderManager {

    @Autowired
    private MailSender mailSender;

    @Autowired
    private SimpleMailMessage simpleMailMessage;

    @Override
    public void placeOrder(Order order) {
        SimpleMailMessage message = new SimpleMailMessage(simpleMailMessage);
        message.setTo(order.getUserEmail());
        message.setSubject(order.getSubject());
        message.setText("Dear:" + order.getUserName() + ",this is Hello World!");
        mailSender.send(message);
    }

}
